package com.huaxin.feignclient.websocket;

import com.huaxin.feignclient.websocket.models.SendMessageRequest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Component
@FeignClient(name = "websocket-client", url = "${feignService.websocket:http://localhost:46835}")
public interface WebsocketClient {
    /**
     * 广播消息给所有连接的客户端
     */
    @PostMapping("/v1/websocket/pushMessage/broadcast")
    ResponseEntity<String> broadcastMessage(@RequestBody SendMessageRequest payload);

    /**
     * 发送消息给指定客户端
     * 请求体示例: {"to": "user1", "message": "你好！"}
     */
    @PostMapping("/v1/websocket/pushMessage/sendToClient")
    ResponseEntity<String> sendToClient(@RequestBody SendMessageRequest payload);
}
